package com.orange.wwwapi.controller.repairOrder;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orange.core.pojo.BR;
import com.orange.core.pojo.PageReqDto;
import com.orange.core.pojo.R;
import com.orange.core.pojo.entity.repairOrder.dto.RepairOrderDTO;
import com.orange.core.pojo.entity.repairOrder.vo.RepairOrderVO;
import com.orange.core.pojo.req.repairOrder.RepairOrderPageQuery;
import com.orange.core.service.repairOrder.RepairOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>ClassName:RepairOrderController</p>
 * <p>Description: 报修管理controller</p>
 * <p>Author: lwm</p>
 * <p>Date: 2025/5/28 22:57</p>
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/repairOrder")
public class RepairOrderController {

    private final RepairOrderService repairOrderService;



    /**
     * 根据id查询报修单信息
     * @param id
     * @return
     */
    @GetMapping("/info/{id}")
    public R<RepairOrderVO> info(@PathVariable("id") Integer id){
        return R.ok(repairOrderService.info(id));
    }

    /**
     * 填写报修单
     * @param repairOrderDTO
     * @return
     */
    @PostMapping
    public R<Boolean> save(@RequestBody RepairOrderDTO repairOrderDTO){
        return BR.result(repairOrderService.save(repairOrderDTO));
    }

    /**
     * 根据商家id分页查询报修单
     * @param pageReqDto
     * @return
     */
    @PostMapping("/pageByMerchantId")
    public R<Page<RepairOrderVO>> pageByMerchantId(@RequestBody PageReqDto<RepairOrderPageQuery> pageReqDto){
        Page<RepairOrderVO> page = repairOrderService.pageByMerchantId(pageReqDto);
        return R.ok(page);
    }

}
